/*
 * @Author: qin
 * @Date:   2018-08-28
 * +----------------------------------------------------------------------
 * | admin [ 后台管理系统公共配置信息 ]
 * | 模板相关接口模块
 * +----------------------------------------------------------------------
 */
layui.define(['jquery', 'configure', 'configureCom', 'bluebird'], function (exports) {
    var configure = layui.configure;
    var configureCom = layui.configureCom;
    var templates = {
        param: {
            searchData: {
                singleProjectId: ''//单位工程ID
            },
            data: {
                singleProjectInfoDetail: {}
            }
        },
        getSingleProjectInfoDetail: function (url) {
            var _url = url || configure.SINGLE_PROJECT_INFO_DETAIL_HTTP.replace('{id}', templates.param.searchData.singleProjectId);
            if (url) {
                templates.param.searchData.singleProjId = templates.param.searchData.singleProjectId;
                delete templates.param.searchData.singleProjectId;
            }
            //获取单位工程信息接口
            return new Promise(function (resolve, reject) {
                configureCom.getAjax(_url, templates.param.searchData).then(function (res) {
                    configureCom.getAjax(configure.UNIT_KCSJ_MSG_HTTP, {singleProjId: templates.param.searchData.singleProjId || templates.param.searchData.singleProjectId}).then(function (dwRes) {
                        res.result.dwRes = dwRes.result;
                        resolve(res);
                    });
                }, function (err) {
                    reject(err);
                });
            });
        },
        getProjectSpecialTypeDetail: function () {
            //获取单位工程中专业类型详情
            return new Promise(function (resolve, reject) {
                configureCom.getAjax(configure.KCDJ_GET_ZYLIST_HTTP, templates.param.searchData).then(function (res) {
                    resolve(res);
                }, function (err) {
                    reject(err);
                });
            });
        },
        getMateriaDetail: function () {
            //获取报审详情
            return new Promise(function (resolve, reject) {
                configureCom.getAjax(configure.REPORT_MASTERIA_DETAIL_HTTP.replace('{singleProjectId}', templates.param.searchData.singleProjectId), templates.param.searchData).then(function (res) {
                    resolve(res);
                }, function (err) {
                    reject(err);
                });
            });
        }
    };
    exports('templates', templates);
});